import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
// import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('asset.assetTransfer.fields');
const { t: common } = useI18n('common');
const assetTransferFields = {
  userIn: t('userIn'),
  userOut: t('userOut'),
  asset: t('asset'),
  userId: t('userId'),
  departmentId: t('departmentId'),
  collectionPositionId: t('collectionPositionId'),
  description: t('description'),
  documentFileString: t('documentFileString'),
  returnTime: t('returnTime'),
  status: t('status'),
  number:t('number'),
  operater:t('operater'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: assetTransferFields.number,
    align: 'center',
    dataIndex: 'id',
  },

  {
    title: assetTransferFields.userIn,
    align: 'center',
    dataIndex: 'userIn_dictText',
  },
  {
    title: assetTransferFields.userOut,
    align: 'center',
    dataIndex: 'userOut_dictText',
  },
  {
    title: assetTransferFields.description,
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: assetTransferFields.status,
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      return render.renderDict(text, 'documentStatus', true, { '2': 'blue', '3': 'green', '4': 'red' });
    },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: assetTransferFields.status,
    field: 'status',
    component: 'JSelectMultiple',
    defaultValue: '1,2',
    componentProps: {
      dictCode: 'documentStatus',
      showChooseOption: false,
      multiple: true,
    },
  },
  {
    label: assetTransferFields.operater,
    field: 'updateBy',
    component: 'JSelectUserByDept',
    componentProps: {
      showButton: false,
    },
  },
  {
    label: assetTransferFields.number,
    field: 'id',
    component: 'JInput',
    componentProps: {
      type: 'like',
    },
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: assetTransferFields.userOut,
    field: 'userOut',
    component: 'JSelectUserByDept',
    dynamicDisabled({ model }) {
      console.log(model, 'model');
      return !!model.id;
    },
    componentProps: {
      showButton: false,
      maxSelectCount: 1,
    },
    dynamicRules: () => {
      return [{ required: true, message: `${common('chooseText')}${assetTransferFields.userOut}!` }];
    },
  },
  {
    label: assetTransferFields.userIn,
    field: 'userIn',
    component: 'JSelectUserByDept',
    componentProps: {
      showButton: false,
      maxSelectCount: 1,
    },
    dynamicRules: () => {
      return [{ required: true, message: `${common('chooseText')}${assetTransferFields.userIn}!` }];
    },
  },
  {
    label: assetTransferFields.description,
    field: 'description',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
